import { _decorator, Component, Node } from 'cc';
import MainPanel from "./MainPanel";
import { SSS_AudioManager } from '../Manager/SSS_AudioManager';

const { ccclass, property } = _decorator;

@ccclass('StartPanel')
export default class StartPanel extends Component {
    public static Instance: StartPanel;

    @property(Node)
    public Button_start: Node | null = null;
    
    onLoad() {
        StartPanel.Instance = this;
    }
    ShowOn() {
        this.node.active = true;
        this.AddListener();
        this.Refresh();
    }
    ShowOff() {
        this.RemoveListener();
        this.node.active = false;
    }
    
    Refresh() {
    }
    AddListener() {
        this.Button_start.on(Node.EventType.TOUCH_END, this.On_Button_start, this);
    }
    RemoveListener() {
        this.Button_start.off(Node.EventType.TOUCH_END, this.On_Button_start, this);
    }
    async On_Button_start() {
        // console.log("On_Button_start---");
        // await UI.Instance.CreatePanel(`UI/MainPanel`, MainPanel);
        MainPanel.Instance.ShowOn();

        SSS_AudioManager.PlayButtonAudio();

        // this.ShowOff();
    }
}
